package com.fjh.roadmannage.ui

import com.cxz.kotlin.baselibs.ext.sss
import com.cxz.kotlin.baselibs.mvp.BasePresenter
import com.cxz.kotlin.baselibs.mvp.IView
import com.fjh.roadmannage.base.Presenter
import com.fjh.roadmannage.bean.User
import com.fjh.roadmannage.http.MainRetrofit

interface LoginContract {
    interface LoginView : IView {
        fun getLoginParam(): Pair<String, String>
        fun loginSuc(user: User)
    }

    class LoginPresenter : Presenter<LoginView>() {
        fun login() {
            addDisposable(
                MainRetrofit.service.login(
                    mView?.getLoginParam()!!.first,
                    mView?.getLoginParam()!!.second
                ).sss(mView, true, {
                    mView?.loginSuc(it)
                })
            )

//            use({
//                MainRetrofit.service.login(
//                    mView?.getLoginParam()!!.first,
//                    mView?.getLoginParam()!!.second
//                )
//            }, {
//                if (it != null) {
//                    mView?.loginSuc(it)
//                }
//            })
        }
    }
}